home *** CD-ROM | disk | FTP | other *** search
/ Champak 123 / (Vol 123) Jan 13 2011.iso / Games / island_fishing.swf / scripts / DefineSprite_161 / frame_2 / DoAction.as
Text File  |  2011-01-13  |  1KB  |  56 lines

  1. flashing = 1;
  2. acceleration = 50;
  3. newpos = function()
  4. {
  5.    ranx = Math.round(Math.random() * 550);
  6.    rany = Math.round(Math.random() * 400);
  7. };
  8. newpos();
  9. this.onEnterFrame = function()
  10. {
  11.    if(hooked <= 0)
  12.    {
  13.       if(ranx > this._x)
  14.       {
  15.          right = 1;
  16.          left = 0;
  17.          this._xscale = -100;
  18.       }
  19.       if(ranx < this._x)
  20.       {
  21.          right = 0;
  22.          left = 1;
  23.          this._xscale = 100;
  24.       }
  25.       this._x += (ranx - this._x) / acceleration;
  26.       if(this._y > 200)
  27.       {
  28.          if(right >= 1)
  29.          {
  30.             myRadians = Math.atan2(rany - this._y,ranx - this._x);
  31.             myDegrees = Math.round(myRadians * 180 / 3.141592653589793);
  32.             this._rotation = myDegrees;
  33.          }
  34.          if(left >= 1)
  35.          {
  36.             myRadians = Math.atan2(rany - this._y,ranx + this._x);
  37.             myDegrees = Math.round(myRadians * 180 / 3.141592653589793);
  38.             this._rotation = myDegrees;
  39.          }
  40.          this._y += (rany - this._y) / acceleration;
  41.          if(rany <= 175)
  42.          {
  43.             newpos();
  44.          }
  45.       }
  46.       else
  47.       {
  48.          this._y += 1;
  49.       }
  50.       if(_root.tmove >= 1)
  51.       {
  52.          newpos();
  53.       }
  54.    }
  55. };
  56.